#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Author : classmate_chen
# @Email : c_l-m@qq.com
# @Time : 2022/10/25 10:51
import sys
import hashlib
 
salt = {
    'r1d': 'A2E371B0-B34B-48A5-8C40-A7133F3B5D88',
    'others': '6D2DF50A-250F-4A30-A5E6-D44FB0960AA0',
}
 
 
def main():
    try:
        sn = sys.argv[1]
    except IndexError:
        sn = input('请输入SN码: ')
 
    print(get_pass(sn))
 
 
def get_pass(sn: str):
    # SN码加盐后进行md5加密取前八位字符串返回
    return hashlib.md5((sn + get_salt(sn)).encode()).hexdigest()[:8]
 
 
def get_salt(sn):
    # 通过判断字符串中是否含有/来获取对应的盐
    if '/' in sn:
        return salt['others'].lower()
    return salt['r1d']
 
 
if __name__ == '__main__':
    main()